import cml from 'chameleon-api';
export default{
    async toLogin({commit,state}, params){
        try {
            console.log(params);
            commit("beginLogin",-1);
            const req = await cml.post({url:'/api/v1/login',data:{params}});
            console.log(req);
            if(req.code == '0000'){
                commit('loginSuccess',req.data);
                //使用redirectTo打开页面用Weex Playground App显示不出来页面？
                cml.navigateTo({
                    path: '/pages/index/index',
                    query: {
                        a: 1,
                        b: 'test'
                    }
                })
            }else{
                commit("beginLogin",0);
                cml.showToast({
                    message:req.message,
                    duration: 2000
                });
            }
        } catch (error) {
            commit("beginLogin",0);
            cml.showToast({
                message:error,
                duration: 2000
            });
        }
    }
}